<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<%
	com.wing.cms.domain.Article article = (com.wing.cms.domain.Article)request.getAttribute("article");	
	String html = htmlEncode(article.getContent());
%>
<html>
<head>
<script charset="utf-8" src="/editor/kindeditor.js"></script>
<script type="text/javascript">

     $(document).ready(function(){
      $.formValidator.initConfig({formid:"articleform",alertmessage:false,onerror:function(msg){alert(msg)}});
      $("#art_name").formValidator({}).inputValidator({min:1,max:256,onerror:"名称不能为空且不能过长，请确认"});
      $("#summary").formValidator({empty:"true"}).inputValidator({min:1,max:1024,onerror:"摘要过长，请确认"});
      $("#author").formValidator({empty:"true"}).inputValidator({min:1,max:60,onerror:"作者不能为空，请确认"});
      $("#keyword").formValidator({empty:"true"}).inputValidator({min:1,max:60,onerror:"关键字过长，请确认"});
      
      
      
});
	  var save = function(){
	       
	      if($.formValidator.pageIsValid()){
				document.getElementById("editor_id").value=KE.html("editor_id");
				var options = {
					type: 'POST',
					async: false,
					dataType: 'content-type',
					success: function(msg) {
						alert("保存成功！");
						
						opener.parentCallback();
					}
				}
				$('#articleform').ajaxSubmit(options);
				window.close();
			}
		}
		
		
		
		function selgrp(oId,oName){
			$('<iframe src="<%=path %>/cms/article/get/selGrpIndex" />').dialog({
                title: '选择所属分组',
                autoOpen: true,
                width: 300,
                height: 300,
                modal: true,
	            buttons: {
					"确定": function() {
						var retv = this.contentWindow.getChannels();
						document.getElementById(oId).value=retv.split("$")[0];
						document.getElementById(oName).value=retv.split("$")[1];
						$( this ).dialog( "close" );
					},
					"关闭": function() {
						$( this ).dialog( "close" );
					}
				}  
            });
		}
</script>
</head>
<body style="text-align: center">
<div style="width:1024;height:100%;background-color:#f1f8fe;margin: 0px auto;">
<form id="articleform"  action="<%=path %>/cms/article/save" method="post" target="_self">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" >
	<thead class="th_nbw">
	<tr>
		<td colspan="2"   style="height:30px;" align="center"><strong>文章管理</strong></td>
	</tr>
	</thead>
</table>
<table align="center" border="0" cellpadding="0" cellspacing="0"  >
	<tr >
		<td align="right"    style="height:5px;" colspan="4"></td>
	</tr>
	<tr >
		<td align="right"  style="height:30px;width:50px">名&nbsp;&nbsp;&nbsp;&nbsp;称：</td>
		<td align="left" colspan="3"><input  style="width:849px" type="text" id="art_name" name="art_name" value="${article.art_name}"></td>
	</tr>
	<tr >
		<td align="right"  style="height:62px;vertical-align: top;"><br/>摘&nbsp;&nbsp;&nbsp;&nbsp;要：</td>
		<td align="left" colspan="3"><textarea  name="summary" id="summary" rows="3" cols="103" style="width:849px;">
			${article.summary}
		</textarea>
		</td>
	</tr>
	<tr >	
		<td align="right"  style="height:30px;width:50px" >作&nbsp;&nbsp;&nbsp;&nbsp;者：</td>
		<td align="left" ><input style="width:153px"  type="text" id="author" name="author" value="${article.author}"></td>
		<td align="right" width="70px">关键字：</td>
		<td align="left"><input style="width:616px"  type="text" id="keyword" name="keyword" value="${article.keyword}"></td>
	</tr>
	<tr >
		<td align="right"    style="height:30px;width:50px">所属组：</td>
		<td align="left"  colspan="3"><input style="width:484px"  type="text" id="grpNames" name="grpNames" value="${grpNames }">
			<input type="hidden" id="grpIds" name="grpIds" value="${grpIds }">
			<input type="button" value="选择" onclick="selgrp('grpIds','grpNames')"/>
		</td>
	</tr>
	<tr >	
		<td align="right"  style="height:30px;width:50px" >排序号：</td>
		<td align="left" ><input style="width:153px"  type="text" id="ordernum" name="ordernum" value="${article.ordernum}"></td>
	</tr>
	<tr >
		<td align="right"    style="height:10px;" colspan="4"></td>
	</tr>
	<tr >
		<td align="right"    style="height:30px;width:50px;vertical-align: top;">内&nbsp;&nbsp;&nbsp;&nbsp;容：</td>
		<td align="left" colspan="3">
			<textarea id="editor_id" name="content" style="width:850px;height:380px;"><%=html %></textarea>
		    <script>
		    	KE.show({
					id : 'editor_id',
					urlType:'absolute',
					imageUploadJson : '<%=request.getContextPath() %>/res/upload',
					fileManagerJson : '<%=request.getContextPath() %>/res/show',
					allowFileManager : true
				});
		    </script>
		</td>
	</tr>
	<tr >
		<td align="right"    style="height:10px;" colspan="4"></td>
	</tr>
	<tr>
		<td align="center" colspan="4">
			<input type="button" onclick="save();" class="button4_nbw" value="保存" />
			<input type="button" onclick="window.close();" class="button4_nbw" value="关闭" />
			<input type=hidden name="id" value="${article.id}" />
			<input type=hidden name="create_user" value="${article.create_user}" />
			<input type=hidden name="valid_flag" value="${article.valid_flag}" />
			<input type=hidden name="status" value="${article.status}" />
			<input type=hidden name="site_id" value="${article.site_id}" />
			<input type=hidden name="create_time_view" value="${article.create_time_view}" />
			<input type=hidden name="article_path" value="${article.article_path}" />
		</td>
	</tr>
</table>
</form>
</div>
<%!

static String htmlEncode(int i){
	if (i=='&') return "&amp;";
	else if (i=='<') return "&lt;";
	else if (i=='>') return "&gt;";
	else if (i=='"') return "&quot;";
	else return ""+(char)i;
}
	
static String htmlEncode(String st){
	StringBuffer buf = new StringBuffer();
	for (int i = 0;i<st.length();i++){
		buf.append(htmlEncode(st.charAt(i)));
	}
	return buf.toString();
}

%>
</body>
</html>


